<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header">
</head>
<link rel="stylesheet" th:href="@{/css/yw.css}">
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .table-border tbody tr td{
        border-top: 1px solid black;
    }
</style>
<section class="content-header">
    <h1>
        商务任务看板
    </h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>项目信息</label>
                                    <input type="text" name="code" class="form-control" placeholder="请输入项目编号或名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>需方</label>
                                    <input type="text" name="demander" class="form-control" placeholder="请输入需方">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>安装地点</label>
                                    <input type="text" name="address" class="form-control" placeholder="请输入安装地点">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>设计科室</label>
                                    <input type="text" name="designDepts" class="form-control" placeholder="请输入设计科室">
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-top: 5px;">
                                    <label>设计类别</label>
                                    <select name="projectClassify" class="form-control" style="width:200px;" id="eqmFkTypeEdit">
                                        <option value="" selected="selected">全部</option>
                                        <option  value="1">设计</option>
                                        <option  value="2">非设计</option>
                                    </select>
                                </div>

                                <div class="form-group" style="margin-right: 10px;">
                                    <label>年份</label>
                                    <select name="isPoint" class="form-control" style="width:140px;" >
                                        <option value="0" selected="selected">全部</option>
                                        <option th:each="yearList:${yearList}" th:value="${yearList.isPoint}" th:text="${yearList.isPoint}+'年'" ></option>
                                        <option  value="2016">2016年及以前</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>任务名</label>
                                    <select name="taskName" class="form-control" style="width:100px;">
                                        <option value="0" selected="selected">全部</option>
                                        <option  value="7">概算</option>
                                        <option  value="1">预算</option>
                                        <option  value="2">报价</option>
                                        <option  value="3">合同</option>
                                        <option  value="4">款票</option>
                                        <option  value="6">核算</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>状态</label>
                                    <select name="taskNameStatus" class="form-control" style="width:100px;">
                                        <option value="0" selected="selected">全部</option>
                                        <option  value="-1">未开始</option>
                                        <option  value="2">执行中</option>
                                        <option  value="3">已完成</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>是否合作项目</label>
                                    <select name="isExpedited" class="form-control" style="width:100px;">
                                        <option value="0" selected="selected">全部</option>
                                        <option  value="1">合作</option>
                                        <option  value="2">非合作</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>成本任务状态</label>
                                    <select name="isAssigned" class="form-control" style="width:100px;">
                                        <option value="">全部</option>
                                        <option  value="-1"  selected="selected">未完成</option>
                                        <option  value="1">已完成</option>
                                    </select>
                                </div>




                                <button type="button" class="btn btn-success" id="btn-search" style="margin-top: 5px;">
                                    <!--<i class="fa fa-search"></i>-->
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"  class="table-border" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer">
</div>
<!--<script th:src="@{/js/yw.js}"></script>-->
<script th:inline="javascript">
    /**
     * 表格搜索
     */
    $("#btn-search").click(function () {
        js.table.search(table);
    });

    /** 加载用户表格 */
    table = js.table.init({
        url: ctx + "taskBase/allTaskList",
        showColumns: false,
        showExport: false,
        pageSize:300,
        columns: [
            {
                title: '序号', field: 'id', width: '50',
                formatter: function (value, row, index, field) {
                    var pageSize = table.bootstrapTable('getOptions').pageSize;
                    var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },

            { title: "项目编号", field: 'code',width:85},
            { title: "项目名称", field: 'name',width:150},
            { title: "需方", field: 'demander'},
            { title: "数量", field: 'num',width:50,
                formatter: function(value, row, index){
                    return value+row.unit;
                }
            },

            { title: "安装地点", field: 'address'},
            { title: "设计科室", field: 'designDepts',width:150,
                formatter: function(value, row, index){
                    return changeRow(value);
                }
            },
            { title: "设计类别", field: 'projectClassify',width:80,
                formatter: function(value, row, index){
                    if(value==1){
                        return '设计';
                    }else if(value==2){
                        return '非设计';
                    }else{
                        return '';
                    }
                }
            },
            { title: "备注", field: 'remark'},
            // { title: "任务类型", field: 'kind',
            //     formatter: function(value, row, index){
            //         if(value==0){
            //             return '看板项目';
            //         }else{
            //             return '销售项目';
            //         }
            //     }
            // },
            { title: "概算", field: 'huikuan',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge" style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label badge bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge" style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label badge label-default">未开始</span>';
                    }
                }
            },
            { title: "预算", field: 'yusuan',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge " style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label  badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label  badge bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge" style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label  badge label-default">未开始</span>';
                    }
                }
            },
            { title: "报价", field: 'baojia',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge " style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label  badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label badge  bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge " style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label badge label-default">未开始</span>';
                    }
                }
            },
            { title: "合同", field: 'hetong',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge " style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label badge bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge " style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label badge label-default">未开始</span>';
                    }
                }
            },
            { title: "款票", field: 'fapiao',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge " style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label badge bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge" style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label badge label-default">未开始</span>';
                    }
                }
            },

            { title: "核算", field: 'hesuan',width:70,
                formatter: function(value, row, index){
                    if(value==-1){
                        return '<span class="label badge " style="background-color:#337ab7;">不需要</span>';
                    }else if(value==2){
                        return '<span class="label badge bg-yellow">执行中</span>';
                    }else if(value==3){
                        return '<span class="label badge bg-green">已完成</span>';
                    }
                    else if(value==-2){
                        return '<span class="label badge " style="background-color:#337ab7;">无</span>';
                    }
                    else{
                        return '<span class="label badge label-default">未开始</span>';
                    }
                }
            },
            // { title: "说明", field: 'remark'},
            {
                title: "操作",
                width: '70',
                formatter: function (value, row, index) {
                    var actions = [];
                    // actions.push('<a class="btn btn-info btn-xs" href="' + ctx + 'taskDetailBoard?id= ' + row.id + '&code='+ row.code + '&name='+ row.name + '&demander='+ row.demander + '&num='+ row.num + '&address='+ row.address + '&projectClassify='+ row.projectClassify + '"> 查看</a> ');

                    actions.push('<a  shiro:hasPermission="task:board:view" class="btn btn-info btn-xs"  target="_blank" href="' + ctx + 'taskDetailBoard?id= ' + row.id + '&code='+ row.code + '"> 查看</a> ');



                    return actions.join('');
                }
            }
        ]
    });

    /**
     * 跳转到详细的页面
     */
    // function detailProject(idd){
    //     js.post({
    //         url: ctx + "taskDetailBoard",
    //         data: null,
    //         success: function (result) {
    //             if (result.type === web_status.SUCCESS) {
    //
    //             } else {
    //                 js.modal.warning(result.msg);
    //             }
    //         }
    //     });
    // }
    function changeRow(value) {
        var code = value;
        var code2 = code.replace(/,/g, "<br/>");
        return code2.replace(/，/g, "<br/>");
    }
</script>